<?php 
if (!defined('BASEPATH'))
	exit ('No direct script access allowed');
	
class Socket_connect{
	public  function connect($time_out,$ip,$port,$json_data,$length) {
		$socket =@socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
		set_time_limit(60);
		$connection =@socket_connect($socket,$ip,$port);
		@socket_write($socket, $json_data);
		$result = @socket_read($socket, $length);
		socket_close($socket);
		return $result;
	}
}